package com.yhg.context.service.impl;

import com.yhg.context.entity.BlBlog;
import com.yhg.context.entity.BlType;
import com.yhg.context.mapper.BlTypeMapper;
import com.yhg.context.service.BlTypeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * <p>
 * 帖子类型表 服务实现类
 * </p>
 *
 * @author 凌月青缃
 * @since 2021-01-21
 */
@Service
public class BlTypeServiceImpl extends ServiceImpl<BlTypeMapper, BlType> implements BlTypeService {

    @Autowired
    BlTypeMapper typeMapper;

    @Override
    public List<BlType> listAll() {
        List<BlType> typeList = typeMapper.listAll();
        return typeList;
    }

    @Override
    public Map<String, Object> getTypeMap() {
        List<BlType> types = baseMapper.listAll();
        Map<String, Object> collect = types.stream().collect(Collectors.toMap(key -> key.getTypeId().toString(), value -> value.getTypeName()));
        return collect;
    }
}
